/**
 * @param {string} s
 * @return {boolean}
 */
var isValid = function (s) {
  const validConfig = {
    '(': ')',
    '{': '}',
    '[': ']'
  }
  const stack = []
  const leftArr = Object.keys(validConfig)
  const strArr = s.split('')
  let res = true
  strArr.forEach(item => {
    if (leftArr.includes(item)) {
      stack.push(item)
    } else {
      const popData = stack.pop()
      if (!popData) {
        res = false
      }
      if (validConfig[popData] !== item) {
        res = false
      }
    }
  })
  if (stack.length !== 0) {
    res = false
  }
  return res
}
console.log(isValid('(]'))
